/*
* @Author: fangshuqin
* @Date:   2018-05-07 14:23:03
* @Last Modified by:   ZHELIHAO\fangshuqin
* @Last Modified time: 2018-05-26 14:55:12
*/

{
    let instance = null;
    class Role extends Sail.Scene {
        constructor () {
            super();
            this.header = null;
            this.rolelist = null;
            this.rolesingle =null;
            this.roledetail = null;
            this.index = null;
            this.mapId = '';

            this.header = new Com.Role.Header();
            this.rolelist = new Com.Role.Rolelist();
            this.roledetail = new Com.Role.Roledetail();
            this.rolesingle    = new Com.Role.Rolesingle();

            this.rolesingle.zOrder= -1;

            this.bg =  new Laya.Image("res/role/bg_role.jpg");
            // this.bg.scale(2, 2);
            this.bg.centerX = 0;
            this.bg.centerY = 0;
            this.bg.zOrder= -2;
            this.addChildren(this.bg,this.header,this.rolelist,this.roledetail,this.rolesingle);
        }

        init(idx, mapId, type) {
            this.index = idx;
            this.mapId = mapId;
            this.type = type;

            this.header.goBackCallBack = this.exit.bind(this);
            this.roledetail.goBackCallBack = this.exit.bind(this);
            this.roledetail.showOrHide(idx, mapId, type);
            Sail.io.emit(GAME_CMDS.GETHEROLIST);
            // Sail.io.emit(GAME_CMDS.GETUSERONEHEROINFO);
        }

        exit () {
       /*     this.rolelist.exit();
            this.rolesingle.exit();
            this.roledetail.exit();*/

            this.removeSelf();
            if(this.index){
                Sail.director.runScene(new Scene.Hall);
            }
        }
        resize (width, height) {
            let rate = height / GAME_CONFIG.HEIGHT;
            this.rolelist.resize(width, height, rate);
            this.roledetail.resize(width, height, rate);
            this.rolesingle.resize(width, height, rate);
        }

        static get I () {
            if(!instance){
                instance = new this;
            }
            return instance;
        }
    }

    Sail.class(Role, "Public.Role");
}